﻿@page "/sayings"
@inherits PageBase

<PageContainer>
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem><Icon Type="home"></Icon></BreadcrumbItem>
            <BreadcrumbItem><Icon Type="smile"></Icon><span>毒鸡汤</span></BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <ChildContent>
        <Card>
            <Table TItem="SayingDto"
                   DataSource="@sayings"
                   Bordered=@true
                   Size=@TableSize.Small
                   Total="total"
                   @bind-PageIndex="page"
                   @bind-PageSize="limit"
                   TitleTemplate="@btn"
                   OnPageIndexChange="HandlePageIndexChange">
                <Column @bind-Field="@context.Id" Title="Id" Sortable="false"></Column>
                <Column @bind-Field="@context.Content" Title="内容" Sortable="false"></Column>
                <ActionColumn Title="操作">
                    <Space Size="@("small")">
                        <SpaceItem>
                            <Popconfirm Title="确定删除吗?"
                                        Icon="close-circle"
                                        OnConfirm="(async () => await DeleteAsync(context.Id))">
                                <Button Danger>删除</Button>
                            </Popconfirm>
                        </SpaceItem>
                    </Space>
                </ActionColumn>
            </Table>
        </Card>
        <Drawer Closable="true"
                Visible="@visible"
                Placement="right"
                Title='("添加鸡汤")'
                Width="500"
                OnClose="_ => Close()">
            <TextArea Placeholder="输入内容" MinRows="5" @bind-Value="@values" />
            <br />
            <br />
            <Button OnClick="OnSubmit" type="@ButtonType.Primary">添加鸡汤</Button>
        </Drawer>
    </ChildContent>
</PageContainer>

@code{
    RenderFragment btn => @<Button Type="@ButtonType.Primary" @onclick="Open" Block="true">添加</Button>;
}